<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>
<html class="">
<head>
	
	<meta name="author" content="蓝凌科技">
	<meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=no">
	<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
	<meta http-equiv="Pragma" content="no-cache" />
	<meta http-equiv="Expires" content="0" />

	<link rel="stylesheet" type="text/css" href="/Public/Api/css/sm.min.css">	
	<link rel="stylesheet" type="text/css" href="/Public/Api/css/sm-extend.min.css">	
	
	<title>帮工小哥</title>
	
	<script type="text/javascript">
	    var _root = '<?php echo ($_site_url); echo U(' / ');?>', _controller = '<?php echo ($_controller); ?>';
	</script>
	
	
	<link rel="stylesheet" type="text/css" href="/Public/Api/css/order.css">


</head>
<body>
	
	

<div class="page-group">
    <div class="page page-current">
        <div class="content">
            <form action="" class="m-phone">
                <ul>
                    <li>
                    	<i class="icon-phone-num">
                    	</i><input type="text" name="tel" id="tel" placeholder="请输入新手机号">
                    </li>
                    <li>
                        <i class="icon-valid"></i><input type="text" name="validation" id="validation" placeholder="请输入验证码"><a class="get-valid" href="#" id="validate">获取验证码</a>
                    </li>
                </ul>
                <div class="confirm">
                    <a class="button button-fill button-big" type="button" onclick="update()">确定</a>
                </div>
            </form>
        </div>
    </div>
</div>




	<!-- 底部
================================================== -->
<footer>
</footer>
<script type="text/javascript">
    (function(){
        var ThinkPHP = window.Think = {
            "ROOT"   : "", //当前网站地址
            "APP"    : "/api.php?s=", //当前项目地址
            "PUBLIC" : "/Public", //项目公共目录地址
            "DEEP"   : "<?php echo C('URL_PATHINFO_DEPR');?>", //PATHINFO分割符
            "MODEL"  : ["<?php echo C('URL_MODEL');?>", "<?php echo C('URL_CASE_INSENSITIVE');?>", "<?php echo C('URL_HTML_SUFFIX');?>"],
            "VAR"    : ["<?php echo C('VAR_MODULE');?>", "<?php echo C('VAR_CONTROLLER');?>", "<?php echo C('VAR_ACTION');?>"]
        }
    })();
    
</script>
<script src="/Public/Api/js/zepto.min.js" type="text/javascript">
</script>
<script type="text/javascript">
//坑死人的配置项
//若不加此配置，则所有页面均使用 js 和 css 缓存
$.config = {
   	router: false
}
</script>
<script src="/Public/Api/js/sm.min.js" type="text/javascript">
</script>
<script src="/Public/Api/js/sm-extend.min.js" type="text/javascript">
</script>
<script src="/Public/Api/js/think.js" type="text/javascript">
</script>


<script type="text/javascript">
$("#validate").click(sendCode);

function sendCode(){
	
	var tel = $.trim($("#tel").val()) || "";
	var type = "3";
	var target = Think.U('Public/validate');
	
	if(!/^1(3|4|5|7|8)\d{9}$/.test(tel))){ 
        $.alert("手机号码格式有误，请确认");  
        return false; 
    }
	
	$.post(target, {'tel':tel, 'type':type}, function(data){
		
		if(data.status == '200'){
			$.alert('发送成功');
			//倒计时120秒
			setTime = 120;
			clearCount = setInterval(countDown,1000);
		}else if(data.status == '108'){
			$.alert('账号已被注册');
		}else if(data.status == '109'){
			$.alert('账号不存在');
		}else if(data.status == '200'){
			$.alert('发送成功');
		}else{
			$.alert('发送失败，请刷新后重试');
		}
	});
}


function countDown(){
	$("#validate").unbind("click");
	$("#validate").html(setTime+"秒后重发");
	setTime--;
	if(setTime <= 0){
		clearInterval(clearCount);
		$("#validate").click(sendCode);
		$("#validate").html("获取验证码");
	}
}

function update(){
	
	var tel = $.trim($("#tel").val()) || "";
	var validation = $.trim($("#validation").val()) || "";
	var target = Think.U('User/updateAccount');
	
	if(!(/^1((3|4|5|8){1}\d{1}|70)\d{8}$/.test(tel))){ 
        $.toast("手机号码格式有误，请确认");  
        return false; 
    }else if(isNaN(validation)){
    	$.toast("验证码错误");  
        return false; 
    }
	
	$.post(target, {'tel':tel, 'validation':validation}, function(data){
		
		if(dataObj.status == '422'){
			$.alert("参数异常");
		}else if(dataObj.status == '103'){
			$.alert('验证码错误');
		}else if(dataObj.status == '108'){
			$.alert('账号已被注册');
		}else if(dataObj.status == '301'){
			$.alert('操作失败');
		}else if(dataObj.status == '200'){
			$.alert('操作成功', function(){
				window.location.href = Think.U('Public/logout');
			});
		}
	});
}
</script>

<!-- 用于加载js代码 -->

</body>
</html>